function login_main(tab)
{
  // Collect form data
  var data = getFormData(tab);

  // Pass data to background page
  getBackgroundPage().saveUserData(data);

  //Navigate to new page
  chrome.tabs.update(data.tabId, {url: "src/html/terminal.html", selected: true, pinned: true});
}

function getFormData(tab)
{
  var machineName = getInputValue("machineName");
  var userName = getInputValue("username");
  var password = getPasswordValue("password");

  debug("Form Submitted with data on tab("+tab.id+") :");
  debug("  Machine Name:"+machineName);
  debug("  User Name:"+userName);
  debug("  Password Length:"+password.length);

  return new userData(tab.id, machineName, userName, password);
}
